package com.zy.dao;

import org.junit.Test;

import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class testJDBC {

	@Test
	public void testJDBC() throws  Exception {
		String url = "jdbc:mysql://localhost:3306/health?characterEncoding=utf8&serverTimezone=UTC";
		String user = "root";
		String password = "123456";
		Class.forName("com.mysql.jdbc.Driver");
		Connection conn = DriverManager.getConnection(url, user, password);
		System.out.println(conn);
		String sql = "select  name  from t_checkitem where  id=30";
		PreparedStatement ps = conn.prepareStatement(sql);
		ResultSet resultSet = ps.executeQuery();
		while (resultSet.next())
		{
			System.out.println(resultSet.getString("name"));
		}

	}
}
